#pragma once

#include <irrlicht.h>
#include <iostream>
#include <sstream>
#include <vector>

#ifdef _WIN32
    #define CURSOR_TEXTURE "..\\Gfx\\Textures\\cursor.png"
    #define FONT "..\\Gfx\\Fonts\\Coolfont.bmp"
#else
    #define CURSOR_TEXTURE "../Gfx/Textures/cursor.png"
    #define FONT "../Gfx/Fonts/Coolfont.bmp"
#endif


using namespace irr;

class ScreenHandler
{
	private:
		IrrlichtDevice* device;
		video::IVideoDriver* driver;
		scene::ISceneManager* smgr;
		
		bool isTyping;
		bool isZooming;
		
		f32 zoomFactor;
		f32 currentZoom;

		scene::ITriangleSelector* inactiveSelector;
		scene::ITriangleSelector* selector;
		scene::ICameraSceneNode* camera;

		std::string chatLog;
	
		gui::IGUIEditBox* chatInputBox;
		
	
		core::dimension2d<u32> currentResolution;
	public:
		ScreenHandler();
		~ScreenHandler();
		
		void setup();
		
		void setTerrainTriangleSelector(scene::ITriangleSelector* newSelector);
		scene::ITriangleSelector* getTerrainTriangleSelector();
		void swapTerrainTriangleSelectors();
		
		void setCameraNode(scene::ICameraSceneNode* newSelector);
		scene::ICameraSceneNode* getCameraNode();
		
		// Get global handles.
		IrrlichtDevice* getDevice();
		video::IVideoDriver* getDriver();
		scene::ISceneManager* getSmgr();
		
		void renderWorld();
		
		void moveCamera();
		void setCurrentZoom(f32 passedDelta);
		
		void drawNames();
		int renderHUD(int lastFPS);
		
		bool getIsTyping();
		void setIsTyping(bool passedValue);

		const wchar_t* getInputBoxContents();

		void showInputBox();
		void hideInputBox();
		void focusInputBox();
		void drawChatLog();
		
		void appendToChatLog(const  std::string& passedString);
		void setChatLog(const std::string& passedChatLog);
		const std::string& getChatLog();
		
		void highlightNode(scene::ISceneNode* node);
		
		void drawStats();

	private:
		void createInputBox();
		void createStatsPane();
};

extern ScreenHandler globalScreenHandler;
